package garden {
	import org.davekeen.flextrine.orm.PersistentCollection;
	import org.davekeen.flextrine.orm.FlextrineError;
  	import garden.Branch;
   	import garden.Garden;
  
	[Bindable]
	public class TreeEntityBase {
		
		public var isUnserialized__:Boolean;
		
		public var isInitialized__:Boolean = true;
		
		public var isCollectionInitializedMap__:Object = new Object();
		
		[Id]
		public var id:String;
		
		public function get type():String { checkIsInitialized("type"); return _type; }
		public function set type(value:String):void { _type = value; }
		private var _type:String;
		
		[Association]
		public function get branches():PersistentCollection { checkIsInitialized("branches"); return _branches; }
		public function set branches(value:PersistentCollection):void { _branches = value; }
		private var _branches:PersistentCollection;
		
		[Association]
		public function get garden():Garden { checkIsInitialized("garden"); return _garden; }
		public function set garden(value:Garden):void { _garden = value; }
		private var _garden:Garden;
		
		public function TreeEntityBase() {
			branches = new PersistentCollection();
		}
		
		public function toString():String {
			return "[Tree id=" + id + "]";
		}
		
		private function checkIsInitialized(property:String):void {
			if (!isInitialized__ && isUnserialized__)
				throw new FlextrineError("Attempt to get property '" + property + "' on unitialized Tree.  Consider using EntityManager::require or eager loading.", FlextrineError.ACCESSED_UNITIALIZED_ENTITY);
		}
		
	}

}
